package com.zimmur.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.mysql.fabric.xmlrpc.base.Array;
import com.zimmur.common.ReturnJsonEntity;
import com.zimmur.common.StatusCodeEnum;
import com.zimmur.model.zone.view.IndexShow;
import com.zimmur.service.IIndexService;


@RestController  
@RequestMapping("/restful/index")  
public class IndexController extends BaseController {
	private static Logger log=LoggerFactory.getLogger(IndexController.class);
	
	 @Resource  
	 private IIndexService indexService;
	/**
	* <p>Title: index</p>
	* <p>Description:首页查询 </p>
	* @param request
	* @param model
	* @return
	 */
	 @ResponseBody
     @RequestMapping(value="/index",method=RequestMethod.GET)  
     public ReturnJsonEntity index(HttpServletRequest request,Model model){
		ReturnJsonEntity entity = new ReturnJsonEntity();
		StatusCodeEnum statusCodeEnum=StatusCodeEnum.CODE100000;
		
		try{
			IndexShow indexShow = indexService.index();
			entity.setData(indexShow);   
			statusCodeEnum = StatusCodeEnum.CODE000000;
		} catch (Exception e) {
			log.error(e.getMessage());
			statusCodeEnum=StatusCodeEnum.CODE100000;
			entity.setData(new Array());
		}
        entity.setCode(statusCodeEnum.getCode());
		entity.setMsg(statusCodeEnum.getMsg());
		return entity;
    }
}
